<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>
<!--工程项目表单-->
<div class="easyui-layout" data-options="fit:true">
	<div class="TableTitle" data-options="region:'north',border:false">
		<span class="label label-primary">导入导出</span>
	</div>
	<div data-options="region:'center'">
		<form id="dom_formProject">
			<input type="hidden" id="entity_id" name="id" value="${entity.id}">
			<table class="editTable">
				<tr>
					<td class="title">导出项目:</td>
					<td colspan="3"><c:if test="${!empty entity}">
							<a href="project/download.do?projectid=${entity.id}">下载</a>
						</c:if> <c:if test="${empty entity}">
							选中项目打开本界面后，可以导出选中项目
						</c:if></td>
				</tr>
				<tr>
					<td class="title">导入项目:</td>
					<td colspan="3"><input type="text" readonly="readonly"
						style="width: 300px;" class="easyui-validatebox"
						data-options="required:true,validType:',maxLength[128]'"
						id="entity_entitytype" name="entitytype"
						value="" />&nbsp;<input type="button"
						id="uploadButton" value="上传文件" /> 
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div data-options="region:'south',border:false">
		<div class="div_button" style="text-align: center; padding: 4px;">
			<a id="dom_cancle_SycnProject" href="javascript:void(0)"
				iconCls="icon-cancel" class="easyui-linkbutton"
				style="color: #000000;">取消</a>
		</div>
	</div>
</div>
<script type="text/javascript">
	var submitAddActionProject = 'project/add.do';
	var submitEditActionProject = 'project/edit.do';
	var currentPageTypeProject = '${pageset.operateType}';
	var submitFormProject;
	$(function() {
		//表单组件对象
		submitFormProject = $('#dom_formProject').SubmitForm({
			pageType : currentPageTypeProject,
			grid : gridProject,
			currentWindowId : 'winProject'
		});
		//关闭窗口
		$('#dom_cancle_SycnProject').bind('click', function() {
			$('#winSycnProject').window('close');
		});
	});
//-->
</script>
<script type="text/javascript">
	$(function() {
		//上次附件
		var uploadbutton = KindEditor.uploadbutton({
			button : KindEditor('#uploadButton')[0],
			fieldName : 'file',
			url : 'upload/general.do',
			afterUpload : function(data) {
				if (data.STATE === 0) {
					$("#entity_entitytype").val(data.id);
					analysisProject(data.id);
				} else {
					if (data.MESSAGE) {
						alert(data.MESSAGE);
					} else {
						alert('请检查文件格式');
					}
				}
			},
			afterError : function(str) {
				alert('自定义错误信息: ' + str);
			}
		});
		uploadbutton.fileBox.change(function(e) {
			uploadbutton.submit();
		});
	});
	
	function analysisProject(fileid){
		$.post('project/import.do', {
			'fileid' :fileid
		}, function(flag) {
			if (flag.STATE == '1') {
				alert(flag.MESSAGE);
			}else{
				alert("导入成功！");
				$('#winSycnProject').window('close');
				$(gridProject).datagrid('reload');
			}
		}, 'json');
	}
</script>